package com.sofwin.yyb.entity;

import java.io.Serializable;
import java.util.List;

public class MyPage implements Serializable {
    private Integer pageNumber; //当前页数
    private Integer pageSize; //当前页面显示条数
    private Integer total; //用户总条数
    private List dataList;

    //总页数，通过计算得
    private Integer pageTotal;
    //首页
    private Integer firstPage;
    //尾页
    private Integer lastPage;
    //上一页
    private Integer prevPage;
    //下一页
    private Integer nextPage;

    public Integer getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(Integer pageNumber) {
        this.pageNumber = pageNumber;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public List getDataList() {
        return dataList;
    }

    public void setDataList(List dataList) {
        this.dataList = dataList;
    }

    /**
     * 计算总页数
     * @return
     */
    public Integer getPageTotal() {
        this.pageTotal = (total-1)/pageSize+1;
        return pageTotal;
    }

    public void setPageTotal(Integer pageTotal) {
        this.pageTotal = pageTotal;
    }

    /**
     * 获取首页
     * @return
     */
    public Integer getFirstPage() {
        this.firstPage = 1;
        return firstPage;
    }

    public void setFirstPage(Integer firstPage) {
        this.firstPage = firstPage;
    }

    /**
     * 尾页
     * @return
     */
    public Integer getLastPage() {
        this.lastPage = this.getPageTotal();
        return lastPage;
    }

    public void setLastPage(Integer lastPage) {
        this.lastPage = lastPage;
    }

    /**
     *计算上一页
     * @return
     */
    public Integer getPrevPage() {
        this.prevPage = this.pageNumber - 1;
        if(this.prevPage < 1){
            this.prevPage = 1;
        }
        return prevPage;
    }

    public void setPrevPage(Integer prevPage) {
        this.prevPage = prevPage;
    }

    /**
     * 计算下一页
     * @return
     */
    public Integer getNextPage() {
        this.nextPage = this.pageNumber + 1;
        if(this.nextPage > this.getPageTotal()){
            this.nextPage = this.getPageTotal();
        }
        return nextPage;
    }

    public void setNextPage(Integer nextPage) {
        this.nextPage = nextPage;
    }
}
